<?php

namespace App\Kuafu\Shop\Model;

use App\Kuafu\Base\Model\BaseModel;
use App\Kuafu\Base\Model\Traits\KfSoftDeletes;
use App\Kuafu\Base\Model\Traits\KfUid;
use App\Kuafu\Pay\Model\PayStreamModel;
use App\Kuafu\Pay\Model\ShopPaymentModel;
use App\Kuafu\Shop\Enum\CodeEnum;
use App\Kuafu\Shop\Enum\ShopCodeEnum;
use App\Kuafu\Shop\Exceptions\ShopException;
use App\Kuafu\User\Model\Role;
use App\Kuafu\User\Model\User;
use App\Kuafu\User\Model\UserRoleMapping;
use App\Kuafu\WaiMai\Enum\WaiMaiDBEnum;
use App\Kuafu\WaiMai\Model\WaiMaiShopMappingModel;
use App\Scope\ShopScope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Redis;

class ShopUnifiedManagementModel extends BaseModel
{
    use HasFactory, KfSoftDeletes, KfUid;

    protected $connection = 'mysql';
    protected $table      = 'shop_unified_managements';

    // 和kfos-api的Store的模型内的枚举同步
    const TYPE_WAIMAI_WHITE = 1; // 外卖白名单
    const TYPE_DOUYIN_WHITE = 2; // 抖音白名单
    const TYPE_WAIMAI_BLACK = 3; // 外卖黑名单，排除用

    const TYPES = [
        self::TYPE_WAIMAI_WHITE => '外卖白名单',
        self::TYPE_DOUYIN_WHITE => '抖音白名单',
        self::TYPE_WAIMAI_BLACK => '外卖黑名单',
    ];

    protected $fillable = [
        'shopId',
        'type',
    ];

    public function shop(): BelongsTo
    {
        return $this->belongsTo(Shop::class, 'shopId', 'id');
    }
}
